package com.diaohw.platform.common.enums;

import com.diaohw.platform.common.util.JsonUtil;
import lombok.Data;
import lombok.experimental.Accessors;

public enum NettyTypeEnum {

    HTTP_LOG, DB_LOG, LOGBACK;


    public static NettyBo parse(String str) {
        return JsonUtil.toBean(str, NettyBo.class);
    }

    public String encode(Object obj) {
        return NettyBo.build(this, JsonUtil.toJsonString(obj));
    }

    @Data
    @Accessors(chain = true)
    public static class NettyBo {
        /**
         * 日志类型
         */
        private NettyTypeEnum type;
        /**
         * 数据
         */
        private String data;

        private static String build(NettyTypeEnum type, String data) {
            NettyBo nettyBo = new NettyBo();
            nettyBo.type = type;
            nettyBo.data = data;
            return JsonUtil.toJsonString(nettyBo);
        }
    }

}


